#include"TcpServer.hpp"
#include"Calculator.hpp"
#include<functional>

Calculator cal;


void DefaultOnMessage(shared_ptr<Connection> Connection_ptr)
{
    //这里进行协议定制
    // cout<<"上层得到了消息"<<Connection_ptr->Inbuffer().c_str()<<endl;
    string response_str = cal.Handler(Connection_ptr->Inbuffer());
    if(response_str.empty()) return;
    lg(Debug, "%s", response_str.c_str());

    //response_str 发送
    Connection_ptr->AppendOutbuffer(response_str);
    // Connection_ptr->_send_cb(Connection_ptr);
    Connection_ptr->_tcp_server_ptr->Sender(Connection_ptr);
}

int main()
{
    unique_ptr<TcpServer> epoll_svr(new TcpServer(8888, DefaultOnMessage));
    epoll_svr->Init();
    epoll_svr->Loop();
    return 0;
}